Skip to content

[docs] Fix non-public entry docs. Various improvements to PTB docs.#25913

Merged
tnowacki merged 9 commits intoMystenLabs:mainfrom
tnowacki:entry-doc
Mar 25, 2026
Merged

[docs] Fix non-public entry docs. Various improvements to PTB docs.#25913
tnowacki merged 9 commits intoMystenLabs:mainfrom
tnowacki:entry-doc

Conversation

@tnowacki
Copy link
Contributor

Description

  • Updated the docs around entry functions.
  • Fixed missing sections for:
    • Move calls
    • TxContext
    • Publish
    • Upgrade

Test plan

  • 👀

Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • Indexing Framework:

@tnowacki tnowacki requested review from a team, damirka and jessiemongeon1 March 20, 2026 16:38
@tnowacki tnowacki temporarily deployed to sui-typescript-aws-kms-test-env March 20, 2026 16:38 — with GitHub Actions Inactive
@vercel
Copy link

vercel bot commented Mar 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sui-docs Ready Ready Preview, Comment Mar 25, 2026 11:35pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
multisig-toolkit Ignored Ignored Preview Mar 25, 2026 11:35pm
sui-kiosk Ignored Ignored Preview Mar 25, 2026 11:35pm

Request Review

Copy link
Contributor

@awelc awelc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some suggestions

Move calls cannot return references (`&T` or `&mut T`). However, this restriction will be lifted in the future.

**Private generics:**
Some framework functions have type parameters that can only be instantiated with types defined in the same module. Since PTBs are not modules, they cannot supply these types and therefore cannot call these functions directly. For example, certain `sui::transfer` functions like `transfer` and `share_object` require a type defined in the calling module, and as such cannot be called from a PTB. Instead, use the `public_transfer` and `public_share_object` variants.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I am being too picky here, but this suggests that public_transfer and public_share_object will always exist. I realize that they should exist if module developers intended transferring/sharing objects declared in the module but perhaps we could make it more explicit. Maybe finish with something like "Instead, use the public_transfer and public_share_object variants. These should be provided by the module developer."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are functions in sui::transfer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aaah, the ones to transfer/share objects with store. The whole thing is more of a nit anyway, but when reading it I thought we are talking objects that actually require module-defined transfer/share functions (and don't have store.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any thoughts on if I should reword this in any way to be more clear?

**Publish:**

- Returns a single `sui::package::UpgradeCap`.
- After the package is staged, the runtime calls each module's `init` function (if present) in module order. `init` receives `&mut TxContext` and optionally a one-time witness. Additional `init` arguments are not yet supported but are planned.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not explicit what "module order" means here


**Cliques**

The system tracks which values are entangled using _cliques_:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like presented in this order, this will be difficult to digest. If possible, I would suggest the following order:

  • describe intuition (even if it does not cover all the corner cases) behind the entry function rules (in particular, what behavior they try to prevent and which behavior they try to allow)
  • give some code examples illustrating this
  • provide a more formal description of the rules via hot cliques

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I have a more formal description, but I have tried to expand on the intuition section above and reiterate it here. There are examples in the following section.

Co-authored-by: Adam Welc <adam@mystenlabs.com>
Co-authored-by: Jessie Mongeon <133128541+jessiemongeon1@users.noreply.github.com>
- If you upgrade a package `P1` to `P2`, other packages and clients that depend on `P1` will continue using `P1`. They do not auto-update to `P2`. Both dependent packages and client code must be explicitly updated to point at `P2`.
- Packages that expect to be extended by dependent packages can avoid breaking their extensions with each upgrade by providing a standard (unchanging) interface that all versions conform to. See the [message sending](https://github.com/wormhole-foundation/wormhole/blob/74dea3bf22f0e27628b432c3e9eac05c85786a99/sui/wormhole/sources/publish_message.move) across a bridge example from Wormhole. Extension packages that produce outbound messages can use [`prepare_message`](https://github.com/wormhole-foundation/wormhole/blob/74dea3bf22f0e27628b432c3e9eac05c85786a99/sui/wormhole/sources/publish_message.move#L68-L90) from any version of the Wormhole package to produce a [`MessageTicket`](https://github.com/wormhole-foundation/wormhole/blob/74dea3bf22f0e27628b432c3e9eac05c85786a99/sui/wormhole/sources/publish_message.move#L52-L66) while client code that sends the message must pass that `MessageTicket` into [`publish_message`](https://github.com/wormhole-foundation/wormhole/blob/74dea3bf22f0e27628b432c3e9eac05c85786a99/sui/wormhole/sources/publish_message.move#L92-L152) in the latest version of the package.
- `public` function signatures cannot be deleted or changed, but `public(friend)` functions can. Use `public(friend)` or private visibility liberally unless you are exposing library functions that will live forever.
- `public` function signatures cannot be deleted or changed, but `public(package)` functions can. Use `public(package)` or private visibility liberally unless you are exposing library functions that will live forever.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

In this invalid PTB, the `HotPotato` from command 0 is still alive in the same clique as `Input(0)` when `spend` is called:

```
// Invalid PTB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would help visually if we used some syntax on these code blocks. Anything that would grey out comments and make commands stand out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will mark them as Move?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe Rust

Copy link
Contributor

@damirka damirka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall with few nits

@tnowacki tnowacki temporarily deployed to sui-typescript-aws-kms-test-env March 25, 2026 21:31 — with GitHub Actions Inactive
…ults.mdx

Co-authored-by: Damir Shamanaev <damirka.ru@gmail.com>
**`TxContext` handling:**
`TxContext` parameters (`&TxContext` or `&mut TxContext`) are automatically injected by the runtime; callers do not supply them. `TxContext` can appear at any position in the parameter list, and a function can have multiple `TxContext` parameters as long as they are immutable (`&TxContext`). These parameters are not counted toward the user-supplied argument count for indexing purposes.

#### Non-public entry function restrictions {#non-public-entry-function-restrictions}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#non-public-entry-function-restrictions will be the anchor for this heading by default, so you don't need to manually define it, just FYI.

…s.mdx

Co-authored-by: Jessie Mongeon <133128541+jessiemongeon1@users.noreply.github.com>
@tnowacki tnowacki temporarily deployed to sui-typescript-aws-kms-test-env March 25, 2026 23:29 — with GitHub Actions Inactive
@tnowacki tnowacki temporarily deployed to sui-typescript-aws-kms-test-env March 25, 2026 23:31 — with GitHub Actions Inactive
@tnowacki tnowacki enabled auto-merge (squash) March 25, 2026 23:31
@tnowacki tnowacki merged commit 5576006 into MystenLabs:main Mar 25, 2026
55 of 56 checks passed
@tnowacki tnowacki deleted the entry-doc branch March 26, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants